CSharpTest.Net
Rollback Method
See Also  Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree<TKey,TValue> Class : Rollback Method

Glossary Item Box

With version 2 storage this will revert the contents of tree to it's initial state when the file was first opened, or to the state captured with the last call to commit. Any transaction log data will be truncated.

Syntax

Visual Basic (Declaration) 
Public Sub Rollback() 
C# 
public void Rollback()

Exceptions

ExceptionDescription
System.InvalidOperationExceptionRaised when called for a BPlusTree that is not using v2 files

Example

BPlusTree/BPlusTree.Test/BasicTestsVersion2.cs

C#Copy Code
using (BPlusTree<int, string> tree = Create(Options))
{
    tree.EnableCount();
    Assert.AreEqual(0, tree.Count);
    tree.Rollback();
    Assert.AreEqual(0, tree.Count);
    tree.Commit();
    Assert.AreEqual(0, tree.Count);

    tree.Add(1, "A");
    tree.Rollback();
    Assert.AreEqual(0, tree.Count);
    tree.Commit();
    Assert.AreEqual(0, tree.Count);

    tree.Add(1, "A");
    tree.Commit();
    Assert.AreEqual(1, tree.Count);
    tree.Rollback();
    Assert.AreEqual(1, tree.Count);

    tree.Add(2, "B");
    tree.Rollback();
    Assert.AreEqual(1, tree.Count);
    tree[1] = "abc";
    tree.Commit();
    Assert.AreEqual(1, tree.Count);
    tree.Rollback();

    Assert.AreEqual("abc", tree[1]);
    Assert.IsFalse(tree.ContainsKey(2));
}
VB.NETCopy Code
Using tree As BPlusTree(Of Integer, String) = Create(Options)
    tree.EnableCount()
    Assert.AreEqual(0, tree.Count)
    tree.Rollback()
    Assert.AreEqual(0, tree.Count)
    tree.Commit()
    Assert.AreEqual(0, tree.Count)

    tree.Add(1, "A")
    tree.Rollback()
    Assert.AreEqual(0, tree.Count)
    tree.Commit()
    Assert.AreEqual(0, tree.Count)

    tree.Add(1, "A")
    tree.Commit()
    Assert.AreEqual(1, tree.Count)
    tree.Rollback()
    Assert.AreEqual(1, tree.Count)

    tree.Add(2, "B")
    tree.Rollback()
    Assert.AreEqual(1, tree.Count)
    tree(1) = "abc"
    tree.Commit()
    Assert.AreEqual(1, tree.Count)
    tree.Rollback()

    Assert.AreEqual("abc", tree(1))
    Assert.IsFalse(tree.ContainsKey(2))
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Generated with Document! X 2011 by Innovasys